<div class="main-content">
	<div class="breadcrumbs" id="breadcrumbs">
		<script type="text/javascript">
			try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
		</script>
 
		<!-- .breadcrumb -->
	</div>
	<div class="page-content">
        
        <div class="page-header">
			<h1>编辑加油站</h1>
		</div>
		<div class="row">
			 <div class="col-xs-12">
				<!-- PAGE CONTENT BEGINS -->
				<form id="usrform" action="<?php echo base_url()."admin/gasstation/edit_gasstation/".$gasstation->id;?>" method="post">
				<input type="hidden" name="id" value="<?php if (isset($gasstation->id))echo $gasstation->id;?>">
				<input type="hidden" name="old_admin_id" value="<?php if (isset($gasstation->id))echo $old_admin_id;?>">
				    <div class="box-body" style="display: inline-block;width: 100%">
				        <div class="form-group col-xs-6">
				            <label>加油站名称：</label>
				            <input name="gasstation_name" type="text" class="form-control" placeholder="输入 ..." value="<?php if (isset($gasstation->gasstation_name))echo $gasstation->gasstation_name;?>" check-type="required">
			            </div>
						<div class="form-group col-xs-6">
				            <label>营业执照注册号：</label>
				            <input name="license" type="text" class="form-control" placeholder="输入 ..." value="<?php if (isset($gasstation->license))echo $gasstation->license;?>" >
			            </div>
			             <div class="form-group col-xs-6">
				            <label>加油站经度(百度)：</label>
				            <input name="longitude" type="text" class="form-control" placeholder="输入 ..." value="<?php if (isset($gasstation->longitude))echo $gasstation->longitude;?>" check-type="required">
			            </div>
			             <div class="form-group col-xs-6">
				            <label>加油站纬度(百度)：</label>
				            <input name="latitude" type="text" class="form-control" placeholder="输入 ..." value="<?php if (isset($gasstation->latitude))echo $gasstation->latitude;?>" check-type="required">
			            </div>
						<div class="form-group col-xs-6">
				            <label>加油站经度(腾讯)：</label>
				            <input name="qq_longitude" type="text" class="form-control" placeholder="输入 ..." value="<?php if (isset($gasstation->qq_longitude))echo $gasstation->qq_longitude;?>" check-type="required">
			            </div>
			             <div class="form-group col-xs-6">
				            <label>加油站纬度(腾讯)：</label>
				            <input name="qq_latitude" type="text" class="form-control" placeholder="输入 ..." value="<?php if (isset($gasstation->qq_latitude))echo $gasstation->qq_latitude;?>" check-type="required">
			            </div>
			             <div class="form-group col-xs-6">
				            <label>加油站地址：</label>
				            <input name="address" type="text" class="form-control" placeholder="输入 ..." value="<?php if (isset($gasstation->address))echo $gasstation->address;?>" check-type="required">
			            </div>
			            <div class="form-group col-xs-6">
				            <label>  银行账号：</label>
				            <input name="bank_card" type="text" class="form-control" placeholder="输入 ..." value="<?php if (isset($gasstation->bank_card))echo $gasstation->bank_card;?>" check-type="required">
			            </div>
						<div class="form-group col-xs-6">
				            <label>  开户支行：</label>
				            <input name="bank_name" type="text" class="form-control" placeholder="输入 ..." value="<?php if (isset($gasstation->bank_name))echo $gasstation->bank_name;?>" >
			            </div>
			            <div class="form-group col-xs-6">
				            <label>打印机编号：</label>
				            <input name="print_sn" type="text" class="form-control" placeholder="输入 ..." value="<?php if (isset($gasstation->print_sn))echo $gasstation->print_sn;?>" check-type="required">
			            </div>
			            <div class="form-group col-xs-6">
				            <label>加油站管理人员</label>
	                            <select name="admin_id" class="form-control" check-type="required">
	                            	<option value="0">请选择管理人员</option>
	                            	<?php if (isset($admin)&&count($admin)>0){
		                            	foreach ($admin as $val){?>
		                            <option value="<?php echo $val->id?>" <?php if ($val->gasstation_id != 0 && $val->id==$gasstation->admin_id){?>selected<?php }?>><?php echo $val->user_name;?></option>
		                            <?php }
		                            	}?>
	                            </select>
			            </div>
			            <div class="form-group col-xs-6">
				            <label>代理商</label>
                            <select name="agent_id" class="form-control" >
                            	<option value="0">请选择代理商</option>
                            	<?php if (isset($agent_list)&&count($agent_list)>0){
	                            	foreach ($agent_list as $val){?>
	                            <option value="<?php echo $val['id']?>" <?php if ($val['id'] != 0 && $val['id']==$agent_id){?>selected<?php }?>><?php echo $val['user_name'];?></option>
	                            <?php }
	                            	}?>
                            </select>
			            </div>
                        <div class="form-group col-xs-6">
				            <label>钉铛会员日（每月8号）</label>
	                            <select name="dingdang_member_day" class="form-control" check-type="required">
	                            	<option value="0" <?php if(empty($gasstation->dingdang_member_day)):?> selected="selected"<?php endif;?>>否</option>
	                            	<option value="1" <?php if(!empty($gasstation->dingdang_member_day)):?> selected="selected"<?php endif;?>>是</option>
	                            </select>
			            </div>
			            <div class="form-group col-xs-6">
				            <label>服务费比率：</label>
				            <input name="fuwu_bl" type="text" class="form-control" placeholder="输入 ..." value="<?php if (isset($gasstation->fuwu_bl))echo $gasstation->fuwu_bl;?>" check-type="required">
			            </div>
                        <div class="form-group col-xs-6">
				            <label>所属城市：</label>
                            <select name="city_id" class="form-control" check-type="required">
	                            	<?php foreach($city as $v):?>
	                            	<option value="<?php echo $v['id']?>" <?php if($gasstation->city_id==$v['id']):?> selected="selected"<?php endif;?>><?php echo $v['name']?></option>
                                    <?php endforeach;?>
	                        </select>
			            </div>
                        <div class="form-group col-xs-6">
				            <label>倒班时间：</label>
				            <input name="daoban" type="text" class="form-control" placeholder="输入1-24整数(默认：8)" value="<?php if (isset($gasstation->daoban))echo $gasstation->daoban;?>" check-type="required">
			            </div>
			            <div class="form-group col-xs-6">
				            <label>油站类别</label>
				            <select name="type">
				            	<option value="0" <?php if($gasstation->type == 0):?>selected<?php endif;?> >暂无</option>
				            	<option value="1" <?php if($gasstation->type == 1):?>selected<?php endif;?> >A类</option>
				            	<option value="2" <?php if($gasstation->type == 2):?>selected<?php endif;?> >B类</option>
				            	<option value="3" <?php if($gasstation->type == 3):?>selected<?php endif;?> >C类</option>
				            </select>
			            </div>
                        <!--
						<div class="col-xs-6" >
				            <label>会员等级（1：开启，0：关闭）：</label>
				            <input name="prestore" type="text" class="form-control" placeholder="输入 ..." value="<?php if (isset($gasstation->prestore))echo $gasstation->prestore;?>" >
			            </div>-->
			            <div class="col-xs-6">
			            	<table class="table table-striped table-bordered table-hover">
			            		<tr>
                                	<td class="text_rt" style="width: 10%;">
                                		<p>营业执照:</p>
                                		<button id="select" type="button">上传</button>
                                	</td>
                                    <td style="width: 80%;">
                                		<div style="width:40%; margin: auto;">
				  							<input type="hidden" id="url" name="yy_zhizhao" value="<?php if (isset($gasstation->yy_zhizhao))echo $gasstation->yy_zhizhao;?>">
				    						<img id="yy_zhizhao" style="width: 100%;" src="<?php if (isset($gasstation->yy_zhizhao)&&$gasstation->yy_zhizhao!=''){echo $gasstation->yy_zhizhao;}else {echo base_url().'themes/default/images/photo_icon.png';}?>" />
										</div>
                                   </td>
                                </tr>
			            	</table>
			            </div>
                        <div class="col-xs-6">
			            	<table class="table table-striped table-bordered table-hover">
			            		<tr>
                                	<td class="text_rt" style="width: 10%;">
                                		<p>油站封面:</p>
                                		<button id="select2" type="button">上传</button>
                                	</td>
                                    <td style="width: 80%;">
                                		<div style="width:40%; margin: auto;">
				  							<input type="hidden" id="image_url" name="image_url" value="<?php if (isset($gasstation->image_url))echo $gasstation->image_url;?>">
				    						<img id="image_url_img" style="width: 100%;" src="<?php if (isset($gasstation->image_url)&&$gasstation->image_url!=''){echo $gasstation->image_url;}else {echo base_url().'themes/default/images/photo_icon.png';}?>" />
										</div>
                                   </td>
                                </tr>
			            	</table>
			            </div>
                    </div>           
                    <div class="clearfix form-actions">
						<div class="col-md-offset-3 col-md-9">
							<button id="btnSubmit" class="btn btn-info" type="submit">
								<i class="icon-ok bigger-110"></i>
								保存
							</button>
							&nbsp; &nbsp; &nbsp;
							<a class="btn" href="<?php echo base_url()."admin/gasstation/index"?>">
								<i class="icon-undo bigger-110"></i>
								返回
							</a>
						</div>
					</div>
				</form>
			</div>
		</div><!-- /.row -->
	</div><!-- /.page-content -->
</div><!-- /.main-content -->
	<script type="text/javascript">
	$("#usrform").validation();
	//保存
	$("#btnSubmit").on('click',function(event){
	  // 2.最后要调用 valid()方法。
	  if ($("#usrform").valid()==false){
	    return false;
	  }
	});
	</script>
	<script>
	$(function () {
        var uploader = null;
        //上传初始化
		if(uploader==null){
        	uploader = WebUploader.create({
        	    // 选完文件后，是否自动上传。
        	    auto: true,
        	    //不压缩图像
        	    compress:false,
        	    // swf文件路径
        	    swf:'<?php echo base_url()?>themes/webuploader/Uploader.swf',
        	    // 文件接收服务端。
        	    server: '<?php echo site_url("admin/upyun/webuploader")?>',
        	    // 选择文件的按钮。可选。
        	    // 内部根据当前运行是创建，可能是input元素，也可能是flash.
        	    pick: '#select',
        	    // 只允许选择图片文件。
        	    accept: {
        	        title: 'Images',
        	        extensions: 'gif,jpg,jpeg,bmp,png',
        	        mimeTypes: 'image/*'
        	    }
        	});
        	//文件上传成功，显示图片。
        	uploader.on('uploadSuccess', function(file,response) {
        		$('#yy_zhizhao').attr('src',response.file_path);
        		uploader.reset();
        		$('#url').val(response.file_path);
        	});

        	// 文件上传失败，显示上传出错。
        	uploader.on( 'uploadError', function( file ) {
        		$('#error').html('上传失败');
        		$('#error').show();
        	});
		}
		
		var uploader2 = null;
        //上传初始化
		if(uploader2==null){
        	uploader2 = WebUploader.create({
        	    // 选完文件后，是否自动上传。
        	    auto: true,
        	    //不压缩图像
        	    compress:false,
        	    // swf文件路径
        	    swf:'<?php echo base_url()?>themes/webuploader/Uploader.swf',
        	    // 文件接收服务端。
        	    server: '<?php echo site_url("admin/upyun/webuploader")?>',
        	    // 选择文件的按钮。可选。
        	    // 内部根据当前运行是创建，可能是input元素，也可能是flash.
        	    pick: '#select2',
        	    // 只允许选择图片文件。
        	    accept: {
        	        title: 'Images',
        	        extensions: 'gif,jpg,jpeg,bmp,png',
        	        mimeTypes: 'image/*'
        	    }
        	});
        	//文件上传成功，显示图片。
        	uploader2.on('uploadSuccess', function(file,response) {
        		$('#image_url_img').attr('src',response.file_path);
        		uploader.reset();
        		$('#image_url').val(response.file_path);
        	});

        	// 文件上传失败，显示上传出错。
        	uploader2.on( 'uploadError', function( file ) {
        		$('#error').html('上传失败');
        		$('#error').show();
        	});
		}

    });
    </script>